package com.example.springbootmybatis.service.impl;

import com.example.springbootmybatis.mapper.UserMapper;
import com.example.springbootmybatis.model.User;
import com.example.springbootmybatis.model.UserExample;
import com.example.springbootmybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: laomao
 * @create: 2019-03-07 10:57
 **/
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper mapper;

    @Override
    public List<User> getList() {
        UserExample example = new UserExample();
        return mapper.selectByExample(example);
    }

    @Override
    public void add(User user) {
        mapper.insertSelective(user);
    }

    @Override
    public void del(int id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(User user) {
        mapper.updateByPrimaryKey(user);
    }
}
